import { getOneHospitalDetailData } from '@/api/hospital/hospitallist';
import { ResHospitalDetailData } from '@/api/hospital/hospitallist/model/hospitalListType';
import { Button, Card, Descriptions } from 'antd'
import React, { useEffect, useState } from 'react'
import { useNavigate, useParams } from 'react-router-dom'

export default function HospitalShow() {
    let navigate = useNavigate();
    //定义状态数据
    let [hospitalshow, setHospitalshow] = useState<ResHospitalDetailData>();
    //接收路由参数
    let { id } = useParams();

    //定义方法完成请求
    const getOneHospitalData = async () => {
        let result = await getOneHospitalDetailData(id as string);
        setHospitalshow(result);
    }

    useEffect(() => {
        //调用
        getOneHospitalData();

        // let obj = { a: 1, b: 2 }
        // //可选运算符
        // console.log(obj?.c)

    }, [])


    return (
        <Card>
            <Descriptions title="基本信息" bordered>
                <Descriptions.Item label="医院名称" span={1}>{hospitalshow?.hospital.hosname}</Descriptions.Item>
                <Descriptions.Item label="医院logo" span={2}>
                    <img src={"data:image/jpeg;base64," + hospitalshow?.hospital.logoData} alt="" width={100} />
                </Descriptions.Item>
                <Descriptions.Item label="医院编码" span={1}>{hospitalshow?.hospital.hoscode}</Descriptions.Item>
                <Descriptions.Item label="医院地址" span={2}>{hospitalshow?.hospital.param.fullAddress}</Descriptions.Item>
                <Descriptions.Item label="坐车路线" span={3}>
                    {hospitalshow?.hospital.route}
                </Descriptions.Item>
                <Descriptions.Item label="医院简介" span={3}>
                    {hospitalshow?.hospital.intro}
                </Descriptions.Item>
            </Descriptions>
            {/* 间距 */}
            <div className='h-20'></div>
            <Descriptions title="预约规则信息" bordered>
                <Descriptions.Item label="预约周期" span={1}>{hospitalshow?.bookingRule.cycle}</Descriptions.Item>
                <Descriptions.Item label="放号时间" span={2}>{hospitalshow?.bookingRule.releaseTime}</Descriptions.Item>
                <Descriptions.Item label="停挂时间" span={1}>{hospitalshow?.bookingRule.stopTime}</Descriptions.Item>
                <Descriptions.Item label="退号时间" span={2}>{hospitalshow?.bookingRule.quitTime}</Descriptions.Item>
                <Descriptions.Item label="预约规则" span={3}>
                    {hospitalshow?.bookingRule.rule}
                </Descriptions.Item>
            </Descriptions>
            {/* 间距 */}
            <div className='h-20'></div>
            {/* 返回按钮 */}
            <Button onClick={() => {
                navigate(-1)
            }}>返回</Button>
        </Card>
    )
}
